package com.strat.searcher.analisys.splite;

import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

public class SplitterUtil {

    private final static String DOCUMENT_PART_PREFIX = "D";

    public static List<String> splitBySentences(Splittable splitter)
            throws Exception {
        List<String> splits = new LinkedList<String>();
        String sentence = null;
        while ((sentence = splitter.nextSplit()) != null) {
            splits.add(sentence);
        }
        return splits;
    }

    public static Map<String, String> prepareForIndexing(List<String> parts) {
        Map<String, String> res = new LinkedHashMap<String, String>();
        int i = 0;
        for (String s : parts) {
            i++;
            res.put(DOCUMENT_PART_PREFIX + i, s);
        }
        return res;
    }
}
